package com.slm.krstartimes.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;

import com.slm.krstartimes.R;

/**
 * Created by dllo on 15/7/24.
 */
public class WelcomeActivity extends Activity {
    private SharedPreferences preferences;
    private SharedPreferences.Editor editor;
    private boolean flag = true;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.welcome_layout);
        preferences = getSharedPreferences("phone", Context.MODE_PRIVATE);
        if (flag) {
            new Handler().postDelayed(new Runnable() {
                public void run() {
                    if (preferences.getBoolean("firstStart", true)) {
                        editor = preferences.edit();
                        editor.putBoolean("firstStart", false);
                        editor.commit();
                        Intent intent = new Intent(WelcomeActivity.this, Guider.class);
                        startActivity(intent);
                        finish();
                    } else {
                        Intent intent = new Intent(WelcomeActivity.this, MainActivity.class);
                        startActivity(intent);
                        finish();
                    }
                }
            }, 3400);
            flag = false;
        }
    }

}
